Skip to content

File attechment submodel - #193

Merged
mm-omdi merged 70 commits into
developfrom
1272-file-attechment-submodel
Aug 7, 2026
Merged

File attechment submodel#193
mm-omdi merged 70 commits into
developfrom
1272-file-attechment-submodel

Conversation

@mm-omdi

@mm-omdi mm-omdi commented Jul 31, 2026

Copy link
Copy Markdown

This pull request introduces comprehensive tests for the new file attachment streaming functionality in the Submodel Repository API, along with related dependency and test setup updates. The main focus is on ensuring that file attachments (such as images or documents) can be retrieved, streamed, and handled securely and correctly, including error handling for edge cases. Several test classes are updated to support and validate these features.

File Attachment Streaming and Testing Enhancements:

  • SubmodelRepositoryControllerTests.cs:

    • Adds tests to verify streaming of file attachments when the submodel element is a file with an HTTP URL, including correct content type and filename handling. Also, tests error cases such as requesting an attachment for a non-file element.
    • Mocks and injects the new IFileAttachmentStreamProvider dependency to support file streaming in tests.
    • Adds test data for plugin responses involving file URLs.
  • SubmodelRepositoryHandlerTests.cs:

    • Adds unit tests for the handler logic that retrieves file attachments, including correct service calls, disposable resource handling, invalid input, and path traversal security checks.
    • Updates constructor and test setup to support HTTP context access for streaming scenarios.
  • SubmodelRepositoryControllerTests.cs (Unit Tests):

    • Adds tests to ensure the controller returns the correct FileStreamResult and passes route values to the handler when serving file attachments.

Dependency Injection and Test Setup:

  • Updates test constructors and dependency injection to include and configure the new IFileAttachmentStreamProvider where required.

Test Data and Configuration Updates:

  • Adds helper methods and data for plugin responses with file attachments.
  • Updates test configuration object initialization for template and general settings.

Minor Fixes and Code Quality:

  • Fixes namespace usage for paging metadata in tests.
  • Updates test logic to use appropriate argument matching for template service calls.
  • Adds missing using statements and minor code style fixes.

These changes significantly improve test coverage for file attachment streaming and ensure the new functionality is robust, secure, and well-integrated with the existing API and service infrastructure.

mm-kgi and others added 30 commits July 2, 2026 09:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Refactor the return statement in `SubmodelRepositoryService.cs` to use the C# 8.0 range operator for improved collection handling.

Add comprehensive unit tests in `GetAllSubmodelsControllerTests.cs` to cover various scenarios for the `GetAllSubmodelsAsync` method, including handling of query parameters, paging, and exception cases. Utilize `NSubstitute` for mocking and `Xunit` for test structuring.
…th semaphore and add configuration for concurrent operations limit
Introduce `_templateManagementOptions` in `SubmodelRepositoryServiceTests` to configure `TemplateManagementConfig` with a `ServiceInstance` and `ConcurrentOperationsLimit`. Update the constructor of `SubmodelRepositoryService` to include the new parameter. Add necessary using directives for configuration and options handling.
…tAllSubmodelsAsync functionality and improve request handling
…SubmodelTemplateAsync for improved query handling
…cluding adjustments to semaphore release and data structure initialization.
@mm-omdi mm-omdi changed the title 1272 file attechment submodel File attechment submodel Aug 3, 2026
mm-omdi added 5 commits August 3, 2026 12:57
…load endpoint; improve response descriptions; correct max file attachment size in configuration files.
- Implemented tests for FileAttachmentStreamProvider to verify response headers and content stream reading.
- Added tests for MaxLengthStream to ensure it correctly enforces maximum byte limits and throws exceptions when exceeded.
- Refactored SubmodelRepositoryHandler to streamline file attachment retrieval logic.
- Updated FileSizeExceededException and InvalidFileUrlException to simplify constructors and messages.
- Introduced MaxLengthStream class to limit stream reading to a specified byte size.
- Modified SubmodelRepositoryService to enhance file URL validation and response handling.
- Updated JSON test data to remove Google Docs viewer URLs in favor of direct file URLs.
- Adjusted SQL load script to reflect changes in document URL handling.
… invalid file element types and empty file URLs.
Comment thread source/AAS.TwinEngine.DataEngine/Infrastructure/Streaming/FileContentProvider.cs Outdated
mm-omdi and others added 11 commits August 4, 2026 10:09
…erface and FileContentProvider class; update SubmodelRepositoryService to use new provider; add unit tests for MaxLengthStream and FileContentProvider.
…r; update exception classes by removing unnecessary comments and whitespace.
…mResult, FileAttachmentResult, and FileContentResponse classes; refactor SubmodelRepositoryService and related components; update exception handling for file size limits; remove obsolete exceptions.
…ControllerTests and SubmodelRepositoryHandlerTests to use new FileContentResponse and LimitedFileStreamResult; adjust assertions and exception handling for improved clarity and accuracy.
…od to return FileStreamResult instead of LimitedFileStreamResult; modify related unit tests for consistency and clarity.
Renamed FileStreamResult to FileContentStreamResult and updated all references, including controller logic and tests, to ensure consistent handling of file attachments with the new result type.
…SuccessStatusCode with explicit check for success status and throw InternalDataProcessingException on failure.
…ests and update exception handling to throw InvalidUserInputException with specific messages.
mm-kgi
mm-kgi previously approved these changes Aug 6, 2026
…dating status code and message retrieval into GetErrorDetails method.
mm-kgi and others added 3 commits August 7, 2026 00:13
…tLength and contentType parameters; update related usages in FileContentProvider and tests.
@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1584
❌ Failed 0
⏭️ Skipped 0

View Detailed Test Results


Code Coverage

Unit Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 91% 78% 2210
Summary 91% (3560 / 3897) 78% (1456 / 1873) 2210

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 61% 42% 2210
Summary 61% (2365 / 3897) 42% (792 / 1873) 2210

@mm-omdi
mm-omdi merged commit 41aaf01 into develop Aug 7, 2026
10 checks passed
@mm-hsh
mm-hsh deleted the 1272-file-attechment-submodel branch August 10, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants